package com.flute.tools.sql;

import java.io.Serializable;
import java.util.LinkedHashSet;

import com.flute.tools.util.StringUtil;

public class FieldsSQL implements ISQL,Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7334138548956597158L;
	private LinkedHashSet<String> fields;

	public FieldsSQL() {
		this.fields = new LinkedHashSet<String>();
	}

	public void addField(String field) {
		this.fields.add(field);
	}

	public void addFields(String[] fields) {
		for (String field : fields) {
			this.fields.add(field);
		}
	}

	public int size() {
		return fields.size();
	}

	@Override
	public String getSQLString() {
		if (fields.size() == 0) {
			return "";
		} else {
			return SQLUtils.BLANK
					+ StringUtil.getStringFromStrings(fields
							.toArray(new String[] {}), ", ") + SQLUtils.BLANK;
		}
	}

}
